# 初始化开发环境脚本
Write-Host "=== 在线学习平台 - 开发环境初始化 ===" -ForegroundColor Green

# 检查MySQL是否运行
Write-Host "检查MySQL服务..." -ForegroundColor Yellow
$mysqlService = Get-Service -Name "MySQL*" -ErrorAction SilentlyContinue
if ($mysqlService -and $mysqlService.Status -eq "Running") {
    Write-Host "✓ MySQL服务已运行" -ForegroundColor Green
} else {
    Write-Host "⚠ 请确保MySQL服务已启动" -ForegroundColor Red
}

# 复制环境变量模板
if (-not (Test-Path ".env")) {
    Copy-Item "env.example" ".env"
    Write-Host "✓ 已创建 .env 文件" -ForegroundColor Green
} else {
    Write-Host "✓ .env 文件已存在" -ForegroundColor Green
}

Write-Host "=== 初始化完成 ===" -ForegroundColor Green
Write-Host "请使用以下命令启动各服务：" -ForegroundColor Cyan
Write-Host "前端: cd frontend && pnpm install && pnpm dev" -ForegroundColor White
Write-Host "后端: cd backend && ./mvnw spring-boot:run" -ForegroundColor White
Write-Host "AI: cd ai && python -m venv .venv && .\.venv\Scripts\Activate.ps1 && pip install -r requirements.txt && python main.py" -ForegroundColor White
